package com.jzoom.zoom.admin.controllers;

import com.jzoom.zoom.admin.models.AuthService;
import com.jzoom.zoom.admin.models.DaoService;
import com.jzoom.zoom.admin.utils.AdminUtils;
import com.jzoom.zoom.common.annotations.Inject;
import com.jzoom.zoom.dao.Dao;
import com.jzoom.zoom.web.action.ActionContext;
import com.jzoom.zoom.web.annotations.Controller;
import com.jzoom.zoom.web.annotations.JsonResponse;

@Controller(key="system")
public class SystemController implements AdminController {


    @Inject("admin")
    private Dao admin;

    @Inject
    private DaoService daoService;

    @Inject
    private AuthService authService;

    @JsonResponse
    public void clearCache(){

        admin.clearCache();

        daoService.clear();
    }


    @JsonResponse
    public void refreshAuth(ActionContext context){
       authService.clearCache(AdminUtils.getToken(context));
    }
}
